<template>
  <div class="home-container">

    <!-- 轮播图 -->
    <div class="carousel-container">
      <el-carousel height="400px" indicator-position="outside">
        <el-carousel-item>
          <div class="carousel-item">
            <img src="https://picsum.photos/1200/400?random=1" alt="非遗剪纸">
            <div class="carousel-text">
              <h2>非遗——过年、剪纸</h2>
              <p>年之序章，福之伊始</p>
            </div>
          </div>
        </el-carousel-item>
        <el-carousel-item>
          <div class="carousel-item">
            <img src="https://picsum.photos/1200/400?random=2" alt="非遗戏曲">
            <div class="carousel-text">
              <h2>非遗——传统戏曲</h2>
              <p>传承经典，品味文化</p>
            </div>
          </div>
        </el-carousel-item>
        <el-carousel-item>
          <div class="carousel-item">
            <img src="https://picsum.photos/1200/400?random=3" alt="非遗手工艺">
            <div class="carousel-text">
              <h2>非遗——传统手工艺</h2>
              <p>匠心独运，技艺传承</p>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- 热门非遗 -->
    <section class="popular-heritages">
      <div class="section-header">
        <h2>热门非遗</h2>
        <p>匠韵千年 薪火相传</p>
        <router-link to="/heritages" class="view-all">查看全部</router-link>
      </div>
      <div class="heritages-grid">
        <div class="heritage-item" v-for="item in popularHeritages" :key="item.id">
          <img :src="item.image" alt="{{ item.name }}">
          <div class="heritage-info">
            <h3>{{ item.name }}</h3>
            <p>{{ item.description }}</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 非遗活动 -->
    <section class="heritage-activities">
      <div class="section-header">
        <h2>非遗活动</h2>
        <p>参与体验 传承文化</p>
        <router-link to="/activities" class="view-all">查看全部</router-link>
      </div>
      <div class="activities-grid">
        <div class="activity-item" v-for="item in activities" :key="item.id">
          <img :src="item.image" alt="{{ item.title }}">
          <div class="activity-info">
            <h3>{{ item.title }}</h3>
            <p class="activity-time">{{ item.time }}</p>
            <p class="activity-location">{{ item.location }}</p>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup>
import { ref } from 'vue'

// 模拟热门非遗数据
const popularHeritages = ref([
  {
    id: 1,
    name: '京剧',
    image: 'https://picsum.photos/300/200?random=4',
    description: '中国五大戏曲剧种之一，形成于北京'
  },
  {
    id: 2,
    name: '昆曲',
    image: 'https://picsum.photos/300/200?random=5',
    description: '中国最古老的戏曲剧种之一'
  },
  {
    id: 3,
    name: '陶艺',
    image: 'https://picsum.photos/300/200?random=6',
    description: '传统手工陶瓷艺术'
  },
  {
    id: 4,
    name: '刺绣',
    image: 'https://picsum.photos/300/200?random=7',
    description: '中国传统工艺'
  }
])

// 模拟非遗活动数据
const activities = ref([
  {
    id: 1,
    title: '非遗剪纸体验活动',
    image: 'https://picsum.photos/300/200?random=8',
    time: '2023-12-20 14:00',
    location: '文化中心一楼大厅'
  },
  {
    id: 2,
    title: '传统戏曲表演',
    image: 'https://picsum.photos/300/200?random=9',
    time: '2023-12-22 19:30',
    location: '大剧院'
  },
  {
    id: 3,
    title: '陶艺制作工作坊',
    image: 'https://picsum.photos/300/200?random=10',
    time: '2023-12-25 10:00',
    location: '艺术中心'
  }
])
</script>

<style scoped>
.home-container {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f5f5;
}


/* 轮播图 */
.carousel-container {
  margin: 20px 0;
}

.carousel-item {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-text {
  position: absolute;
  top: 50%;
  right: 10%;
  transform: translateY(-50%);
  text-align: center;
  color: #1a5276;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 20px 40px;
  border-radius: 8px;
}

.carousel-text h2 {
  font-size: 36px;
  margin-bottom: 10px;
}

.carousel-text p {
  font-size: 18px;
}

/* 热门非遗 */
.popular-heritages,
.heritage-activities {
  width: 90%;
  margin: 40px auto;
  background-color: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.section-header h2 {
  font-size: 28px;
  color: #1a5276;
  margin: 0;
}

.section-header p {
  font-size: 16px;
  color: #666;
  margin: 5px 0 0 0;
}

.view-all {
  color: #3498db;
  text-decoration: none;
  font-size: 16px;
}

.view-all:hover {
  text-decoration: underline;
}

.heritages-grid,
.activities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.heritage-item,
.activity-item {
  background-color: #f9f9f9;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.heritage-item:hover,
.activity-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.heritage-item img,
.activity-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.heritage-info,
.activity-info {
  padding: 15px;
}

.heritage-info h3,
.activity-info h3 {
  font-size: 20px;
  color: #1a5276;
  margin-bottom: 10px;
}

.heritage-info p {
  color: #666;
  line-height: 1.6;
}

.activity-time,
.activity-location {
  color: #666;
  margin: 5px 0;
  font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    gap: 10px;
  }
  
  .nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .carousel-text h2 {
    font-size: 24px;
  }
  
  .carousel-text p {
    font-size: 16px;
  }
  
  .section-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}
</style>
